#!/bin/bash
[ $# -eq 0 ] && { echo "Usage: $0 TEST_DIR WORDS_FILE"; exit 1; }
words=$2

#
cat $words | while read WORD
do
	cd annotations
		cat $WORD-annotations.txt \
		| sed 's/<.*instance="\([0-9]*\)".*senseid="\([0-9]*\).*/\1 \2/' \
		| while read instance senseid
		
		do
			cat ../$1/$WORD/$WORD-corpus.xml \
			| grep -A 5 "<instance id=.$instance.>" \
			| sed -e "s/\(.*senseid=\"\)NOTAG\(\".*\)/\1$senseid\2/" >> $WORD-test.xml
			cp $WORD-test.xml ../$1/$WORD/LEXELT-test.xml
		done	
	cd ..
done